<template>
	<!-- 登录框 -->
	<view class="pages">
		<view class="boat">
			<view class="title">泾彩产业新质驱动平台</view>
			<view class="border">

				<button class="btn" @click="login">
					立即登录
				</button>
				<view class="closebtn" @click="SetUserInfo">暂不登录</view>
			</view>
			<image src="https://upload.file.jingcaijinghe.com/files/img/2024/01/12/1705044292336746.png" mode="widthFix"
				class="img"></image>
		</view>
	</view>
</template>

<script>
	export default {
		onLoad() {
			uni.hideShareMenu()
		},
		data() {
			return {}
		},
		methods: {
			login() {
				let that = this;
				wx.login({
					success(res) {
						if (res.code) {
							//发起网络请求
							that.$func.request('/auth/openid', {
								code: res.code
							}, 'POST').then(res => {
								that.$cache.setCache('token', res.data.token, 85000)
								uni.showToast({
									title: '登录成功',
									icon: 'none'
								})
								uni.navigateBack({
									delta: 1
								})
							})
						} else {
							console.log('登录失败！' + res.errMsg)
						}
					}
				})
			},

			SetUserInfo() {
				uni.navigateBack({
					delta: 1
				})
			},

		}
	}
</script>

<style>
	.pages {
		display: flex;
		justify-content: center;
		align-items: center;
		width: 750rpx;
		margin-top: 100rpx;
	}


	.boat {
		width: 100%;
	}

	.title {
		text-align: center;
		font-weight: bold;
		font-size: 48rpx;
		color: #FF7F00;
		margin: 100rpx auto;
	}

	.border {
		width: 100%;
		display: flex;
		align-items: center;
		flex-direction: column;
	}


	.sings {
		padding: 54rpx 124rpx 0 124rpx;
		display: flex;
	}

	.sings text {
		color: rgba(51, 51, 51, 1);
		font-size: 32rpx;
	}

	.singe {
		padding-top: 20rpx;
		display: flex;
	}

	.singe text {
		color: #999999;
		font-size: 28rpx;
	}


	.btn {
		margin-top: 32rpx;
		width: 500rpx;
		height: 80rpx;
		border-radius: 100rpx;
		background: #FF7F00;
		font-size: 32rpx;
		font-weight: 400;
		color: #FFFFFF;
		line-height: 80rpx;
		text-align: center;
	}

	.closebtn {
		margin-top: 32rpx;
		width: 500rpx;
		height: 80rpx;
		border-radius: 100rpx;
		background: #E6E6E6;
		font-size: 32rpx;
		font-weight: 400;
		text-align: center;
		line-height: 80rpx;
		color: #aaa;
	}

	.img {
		width: 100%;
	}
</style>